<template>
  <div>
    <div class="title content">
      <img src="../../public/images/logo.png">
      <div class="search">
        <input v-model="input" placeholder="搜索课程" class="searchText">
        <div class="searchIcon" @click="goSearch">搜索</div>
      </div>
      <div class="titleIcon">
        <i class="el-icon-shopping-cart-2 shopping"></i>
        <span>
          <Login></Login>
        </span>
        <div class="user">
          <el-dropdown>
            <span class="el-dropdown-link">
             <i class="el-icon-user-solid"></i>
           </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item><span @click="personalCenter(1)">个人中心</span></el-dropdown-item>
              <el-dropdown-item><span @click="personalCenter(2)">我的课程</span></el-dropdown-item>
              <el-dropdown-item><span @click="personalCenter(3)">我的订单</span></el-dropdown-item>
              <el-dropdown-item><span @click="loginBack">退出登录</span></el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>

    </div>
    <MyMessageIndex />
  </div>
</template>
<script>
import Login from "@/views/user/components/Login";
import MyMessageIndex from "@/views/user/MyMessage/MyMessageIndex";
export default {
  components: {
    Login,
    MyMessageIndex
  }
}
</script>
<script>

import Login from "@/views/user/components/Login";
import {getClassseach} from "@/api/seach-api";
import {modifyLogout} from "@/api/user-api";
import {mapState} from "vuex";

export default {
  name: "IndexTitle",
  components: {
    Login,
  },
  data() {
    return {
      input: '',
    }
  },
  methods: {
    //搜索页
    goSearch() {
      this.$router.push({
        path: '/SearchPage',
        query: {
          keyword: this.input,
          subjectId: '',
          type: '',
          courseType: ''
        }
      })
    },
    personalCenter(e) {
      console.log(e)
      this.$router.push({path: '/IndexPaging/?e='+ e})
    },
    loginBack() {
      modifyLogout().then(res => {
        if (res.code === 0) {
          this.$message({
            showClose: true,
            message: '恭喜你，退出登录',
            type: 'success'

          });
          this.$store.commit('changeUserInfo',{userInfos:null})
        }
      })
    }
  },
  computed:{
    ...mapState(['userInfos'])
  }
}
</script>

<style scoped lang="less">
.el-dropdown-link {
  cursor: pointer;
  color: #00cf8c;
}

.el-icon-arrow-down {
  font-size: 12px;
}

.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}

.content {
  width: 1200px;
  margin: 0 auto;
}

.title {
  font-size: 18px;
  //display: flex;
  overflow: hidden;


  img {
    float: left;
    height: 55px;
    margin-top: 22px;
    margin-right: 200px;
  }

  .search {
    float: left;
    width: 400px;
    margin: 30px 6px 0 0;

    border-radius: 40px;
    border: 1px solid #999999;
    overflow: hidden;

    .searchText {
      float: left;
      width: 280px;
      outline: none;
      height: 40px;
      border: none;
      padding: 0;
      padding-left: 20px;
    }

    .searchIcon {
      float: left;
      width: 100px;
      height: 40px;
      line-height: 40px;
      text-align: center;
      background-color: rgb(0, 207, 140);
      color: white;
    }
  }

  //.titleIcon{
  //  height: 100%;
  //  float: right;
  //  margin-right: 100px;
  //  //font-size: 14px;
  //  padding: 32px 0 0;
  //  .shopping{
  //    color: #aaa;
  //  }
  //  span{
  //    margin: 0 10px;
  //  }
  .titleIcon {
    margin-right: 100px;
    font-size: 14px;
    padding: 32px 0 0;

    height: 100%;
    display: flex;
    justify-content: space-between;

    .shopping {
      color: #aaa;
      margin-left: 181px;
      margin-top: 12px;
    }

    span {
      margin: 0 10px;
    }

    .user {
      display: inline-block;
      line-height: 32px;
      text-align: center;
      width: 32px;
      color: #ffffff;
      height: 32px;
      background-color: #cccccc;
      border-radius: 50%;
    }
  }
}
</style>